package test1;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) {
        //数据的获取
        try (
                Connection connection=DBUtil.getConnection();
                ){
            Statement statement=connection.createStatement();
            String sql="SELECT id,from_user,to_user,content FROM chatinfo  ";

            ResultSet rs =statement.executeQuery(sql);
            while (rs.next()){
                int id=rs.getInt("id");
                String from_user=rs.getString("from_user");
                String to_user=rs.getString("to_user");
                String content=rs.getString("content");
                System.out.println(id+" "+from_user+" "+to_user+" "+content);
            }

        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
